package startupcompanymanager2012;

import java.io.*;
import java.util.ArrayList;

public class Name {

    public static String generate() {

        ArrayList<String> vName = new ArrayList<String>();
        ArrayList<String> nName = new ArrayList<String>();
        try {
            FileInputStream fstream = new FileInputStream("FirstNames.dat");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;

            while ((strLine = br.readLine()) != null) {
                vName.add(strLine);
            }
            //Close the input stream
            in.close();
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }

        try {
            FileInputStream fstream = new FileInputStream("LastNames.dat");
            DataInputStream in = new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;

            while ((strLine = br.readLine()) != null) {
                nName.add(strLine);
            }
            //Close the input stream
            in.close();
        } catch (Exception e) {//Catch exception if any
            System.err.println("Error: " + e.getMessage());
        }

        String str = "" + vName.get((int) (Math.random() * vName.size())) + " "
                + nName.get((int) (Math.random() * nName.size()));
        return str;

    }
}
